﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="product_list.aspx.cs" Inherits="Com.CMS263.Web.manage.ProductManage.product_list" %>

<%@ Import Namespace="Com.CMS263.PO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>后台-产品管理</title>
    <link href="/manage/css/common.css" rel="stylesheet" type="text/css" />
    <link href="/manage/css/main.css" rel="stylesheet" type="text/css" />
    <link href="/manage/css/box.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript" src="/manage/js/common.js"></script>

    <script language="javascript" type="text/javascript" src="/manage/js/pager.js"></script>

    <script language="javascript" type="text/javascript" src="/manage/js/jquery-1.4.2.min.js"></script>

    <script type="text/javascript" language="javascript">
        function Del(id, obj) {
            if (confirm("确认删除该条数据吗")) {
                $.post("product_action.aspx?op=del", { id: id }, function(data) {
                    if (data == '1') {
                        alert("删除成功");
                        $(obj).parent().parent().remove();
                    }
                    else {
                        alert("删除失败");
                    }
                })
            }

        }
        function updateItem(id, obj) {
            $.post("product_action.aspx?op=updateItem", { id: id }, function(data) {
                if (data == '1') {
                    $(obj).html("正常");
                }
                else if (data == '0') {
                    $(obj).html("<span style='color:red'>已下架</span>");
                }
                else {
                    alert("修改失败");
                }
            })
        }
        $(function() {
            $("#txtSearchType").val("<%=typeid %>");
            $("#txtSearchStyle").val("<%=styleid %>");
        })
    </script>

</head>
<body>
    <form id="form1" name="form1" runat="server" action="product_list.aspx" method="post"
    onsubmit="javascript:if(checkForm()){this.submit();};">
    <div class="main">
        <div class="mainMenu">
            <div class="mainMenuList">
                <ul>
                    <li><a href="product_add.aspx"><b>添加商品</b><span></span></a></li>
                    <li class="s"><a href="product_list.aspx"><b>商品列表</b><span></span></a></li>
                </ul>
            </div>
        </div>
        <div class="mainContent">
            <div class="productSearch">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
                    <tr>
                        <td width="80" class="c">
                            商品类型
                        </td>
                        <td width="160" class="c">
                            <select name="txtSearchType" id="txtSearchType" class="input1" style="width: 155px">
                                <option value="0">全部</option>
                                <option value="1">婚纱</option>
                                <option value="2">喜酒</option>
                                <option value="3">喜帖</option>
                                <option value="4">珠宝</option>
                                <option value="5">礼品</option>
                            </select>
                        </td>
                        <td width="80" class="c">
                            所属规模
                        </td>
                        <td width="160" class="c">
                            <select name="txtSearchStyle" id="txtSearchStyle" class="input1" style="width: 155px">
                                <option value="0">全部</option>
                                <option value=",100,">100</option>
                                <option value=",150,">150</option>
                                <option value=",200,">200</option>
                            </select>
                        </td>
                        <td class="c">
                            <asp:Button ID="btnSearch" runat="server" Text="搜索" OnClick="btnSearch_Click" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="productList">
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table2">
                    <tr>
                        <th width="40" class="c">
                            排序
                        </th>
                        <th class="c">
                            名称
                        </th>
                        <th width="100" class="c">
                            编号
                        </th>
                        <th width="100" class="c">
                            价格
                        </th>
                        <th class="c" width="150">
                            简介
                        </th>
                        <th class="c" width="150">
                            图片
                        </th>
                        <th width="40" class="c">
                            分类
                        </th>
                        <th width="40" class="c">
                            状态
                        </th>
                        <th width="80" class="c">
                            图片管理
                        </th>
                        <th width="40" class="c">
                            操作
                        </th>
                    </tr>
                    <% foreach (Product prod in prodlist)
                       {%>
                    <tr>
                        <td class="c">
                            <%=prod.SortId %>
                        </td>
                        <td class="c">
                            <font class="f11">
                                <%=prod.Title %></font>
                        </td>
                        <td>
                            <%=prod.ProductNum %>
                        </td>
                        <td>
                            <%=prod.SalePrice %>
                        </td>
                        <td class="c">
                            <%=Com.CMS263.Util.StringUtil.GetText(prod.ProductDescription,40) %>
                        </td>
                        <td class="c">
                            <img src="/artupfile/<%=prod.ProductImg %>" width="100" height="100" class="border1" />
                        </td>
                        <td class="c">
                            <%=GetTypeName(prod.ProductType)%>
                        </td>
                        <td class="c">
                            <a style="cursor: pointer" onclick="updateItem(<%=prod.Id %>,this)" class="c369">
                                <%=prod.IsPub==true?"正常":"<span style='color:red'>已下架</span>" %></a>
                        </td>
                        <td class="c">
                            <a style="cursor: pointer" href="product_img_list.aspx?productPage=1&ProductId=<%=prod.Id %>"
                                class="c369">点击进入</a>
                        </td>
                        <td class="c">
                            <a style="cursor: pointer" onclick="Del(<%=prod.Id %>,this)" class="c369">删除</a><br />
                            <a href="product_edit.aspx?id=<%=prod.Id %>" class="c369">修改</a>
                        </td>
                    </tr>
                    <%} %>
                    <tr>
                        <td colspan="8">
                            <div style="float: right; margin-right: 100px">
                                <%=GetPager()%></div>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
